package main

import "fmt"

func main() {
	var b bool = false
	var i int32 = 99
	var f float64 = 99.9
	var s string = "张三"
	var bt byte = 'a'
	var arr [3]int
	typeJudge(b, i, f, s, bt, arr)
	//index=0 bool false
	//index=1 int 99
	//index=2 float 99.9
	//index=3 string 张三
	//index=4 byte 97
	//index=5 不确定 [0 0 0]

}

// 类型判断的方法
func typeJudge(items ...interface{}) {
	for index, item := range items {
		switch item.(type) { //item.(type) 固定写法
		case bool:
			fmt.Printf("index=%d bool %v \n", index, item)
		case int, int64, int32, int8, uint, uint64, uint32, uint16:
			fmt.Printf("index=%d int %v \n", index, item)
		case float64, float32:
			fmt.Printf("index=%d float %v \n", index, item)
		case string:
			fmt.Printf("index=%d string %v \n", index, item)
		case byte:
			fmt.Printf("index=%d byte %v \n", index, item)
		default:
			fmt.Printf("index=%d 不确定 %v \n", index, item)
		}
	}
}
